package dao.impl;

import dao.CategoryDao;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import pojo.Category;
import utils.JdbcUtils;

import java.sql.SQLException;
import java.util.List;

/**
 * @author LiangHaiBo
 * @version 1.0
 * @date 2021.9.7 上午 9:07
 */
public class CategoryDaoimpl implements CategoryDao {

    @Override
    public List<Category> selectCategoryall() {
        try {
            QueryRunner qr = new QueryRunner(JdbcUtils.getDataSource());
            String sql  = "select * from category";
            List<Category> list = qr.query(sql, new BeanListHandler<Category>(Category.class));
            return list;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
